package com.easylinkin.linkappapi.ruleengine.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.easylinkin.linkappapi.intelligentrule.entity.IntelligentRuleExpression;
import com.easylinkin.linkappapi.ruleengine.entity.RuleTrigger;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import java.util.List;
import org.apache.ibatis.annotations.Param;

/**
 * <p>
 * 规则触发器 Mapper 接口
 * </p>
 *
 * @author TongJie
 * @since 2020-08-24
 */
public interface RuleTriggerMapper extends BaseMapper<RuleTrigger> {

    List<RuleTrigger> getRuleTriggers(@Param("ruleTrigger") RuleTrigger ruleTrigger);

    IPage<RuleTrigger> getRuleTriggers(@Param("page") Page page, @Param("ruleTrigger") RuleTrigger ruleTrigger);

    RuleTrigger getRuleTrigger(@Param("id") String id);

    /**
     * 查询 触发器以及表达式
     */
    List<RuleTrigger> getRuleTriggersAndExpressions(@Param("ruleTrigger") RuleTrigger ruleTrigger);


    List<IntelligentRuleExpression> selectExpressionAndAttrByRuleTriggerId(@Param("id") String id);

    /**
     * 通过设备code 查询 关联的触发器
     *
     * @param deviceCode 设备编码
     */
    List<RuleTrigger> getRuleTriggersByRelatedDeviceCode(@Param("deviceCode") String deviceCode,@Param("tenantId") String tenantId);

    int batchInsert(@Param("list") List<RuleTrigger> list);
}
